package com.spddr.pmos.jpa;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Embeddable;

import org.joda.time.LocalDate;

@Embeddable
public class CustomerEvalId implements java.io.Serializable {
	private static final long serialVersionUID = 1L;

	private LocalDate date;
	private long customer;

	public CustomerEvalId() {
	}

	public CustomerEvalId(LocalDate date, long customer) {
		this.date = date;
		this.customer = customer;
	}

	@Column(name = "date", nullable = false, length = 10)
	@Convert(converter = cn.seqdata.jpa.converter.LocalDateConverter.class)
	public LocalDate getLocalDate() {
		return this.date;
	}

	public void setLocalDate(LocalDate date) {
		this.date = date;
	}

	@Column(name = "customer", nullable = false)
	public long getCustomer() {
		return this.customer;
	}

	public void setCustomer(long customer) {
		this.customer = customer;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (customer ^ (customer >>> 32));
		result = prime * result + ((date == null) ? 0 : date.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		CustomerEvalId other = (CustomerEvalId) obj;
		if (customer != other.customer)
			return false;
		if (date == null) {
			if (other.date != null)
				return false;
		} else if (!date.equals(other.date))
			return false;
		return true;
	}
}